package com.feilong.edgeAI.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

import com.feilong.edgeAI.utils.AppUtils;

import java.util.Locale;

/**
 * Created by【仿脑科技】
 *
 * @Author: potato
 * @CreateDate: 2024/1/25 11:31
 */
public class LanguageChangeReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        if (Intent.ACTION_LOCALE_CHANGED.equals(intent.getAction())) {
            // 获取当前的语言和国家设置
            Locale locale = Locale.getDefault();
            String language = locale.getLanguage();
            String country = locale.getCountry();
            AppUtils.initFeilong();
            Log.d("LanguageChangeReceiver", "System language changed to: " + language + "-" + country);

            // 根据新的语言设置更新你的应用界面或资源
            // 这里可以进行相应的逻辑处理，例如重新加载本地化字符串、重启活动等
            // ...
        }
    }
}